<?php
/**
 * Created by PhpStorm.
 * User: yiyu
 * Email: smalleasyu@gmail.com
 * Date: 2020-02-03 19:16:40
 * Desc:
 */

namespace app\admin\service;

use app\base\service\BaseService;
use app\base\model\user\User;
use app\base\model\order\Order;
use app\base\model\goods\GoodsGroupInfo;

class HomeService extends BaseService
{

    public static function getUserNum($where = [])
    {
        return User::where($where)->count();

    }

    public static function getPayMoney($where = [])
    {
        return Order::where('order_state', Order::ORDER_SUCCESS)->where('is_robot', 0)->where($where)->sum('pay_money');//pay_money
    }

    public static function getInitiateNum($where = [])
    {
        return GoodsGroupInfo::where($where)->count();
    }

    public static function getInitiateUserNum($where = [])
    {
        return GoodsGroupInfo::where($where)->group('user_id')->count();
    }

    public static function getGroupSuccessNum($where = [])
    {
        return GoodsGroupInfo::where($where)->where('group_state', GoodsGroupInfo::GROUP_SUCCESS_STATE)->count();
    }

    public static function getGroupSuccessUserNum($where = [])
    {
        return GoodsGroupInfo::where($where)->where('group_state', GoodsGroupInfo::GROUP_SUCCESS_STATE)->group('user_id')->count();
    }


}